//
//  MoreAboutViewController.m
//  OrderSeat
//
//  Created by haiming on 13-10-17.
//  Copyright (c) 2013年 wangwei. All rights reserved.
//

#import "AboutViewController.h"

@implementation AboutViewController

- (id)init
{
    self = [super init];
    if (self) {
        _dataSource = [[AbountDataSource alloc] initWithVC:self];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setupUI];
    
    [_dataSource fetchAboutInfo];
}

#pragma 隐藏tabbar
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [[AppDelegate sharedInstance] hideTabBar:self.tabBarController];
}

- (void)setupUI
{
    [self createLeftButton];
    [self setNavigationTitle:@"关于美滋美位"];

    [_contentView drawBorder];
}

- (void)leftButtonClick:(id)sender
{
    [[AppDelegate sharedInstance] showTabBar:self.tabBarController];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)setFormValues:(NSDictionary*)dic
{
    _contentLabel.text = [dic objectForKey:@"jieshao"];
    [_contentLabel autoHeightForMutiLines];
    _contentLabel.height += 20;
    [_contentView autoHeight];
}

@end

//==============================================================================
#pragma=========数据源实现========================================================
//==============================================================================

@implementation AbountDataSource

- (id)initWithVC:(id)viewController
{
    self = [super init];
    if (self) {
        self.viewController = viewController;
    }
    return self;
}

- (void)fetchAboutInfo
{
    [self get:API_ABOUT];
}

- (void)requestFinished:(ASIHTTPRequest *)request
{
    CLog(@"%@",request.responseString);
    
    NSDictionary *json = [request.responseData JSONValue];
    if ([[json objectForKey:@"error_code"] intValue] == 0) {
        [_viewController setFormValues:json];
    }
}

@end
